<?php
/***
 * Provides easy rendering of different styles. Styles consist of atleast one 
 * .php file in a structure like:
 *
 *     planet/styles/nameOfStyle/nameOfStyle.php
 *
 * A style may reference JavaScript, CSS, and any other files from any other
 * location, but for the sake of manageability, please keep all files in the
 * same directory.
 *
 * For examples of how a style is built, see the default style in the styles
 * directory.
 */
class Style {
	
	/***
	 * $options['directory']
	 *   The directory in which we'll look for style files. Default should be ok
	 *   in almost all cases.
	 *   
	 * $options['style']
	 *   Name of the default style to use. Don't set this here, but in the
	 *   configuration file.
	 **/
	var $options = array(
		'directory' => 'styles',
		'style' => 'default'
	);
	
	var $variables = array();
	
	public function __construct($options = array()) {
		$this->options = array_merge($this->options, $options);
	}
	
	public function set($name = null, $value) {
		$this->variables[$name] = $value;
	}
	
	public function render() {
		extract($this->variables);

	    ob_start();
	    include(join('', array(
					$this->options['path'],
					'styles/',
					$this->options['style'],
					'/',
					$this->options['style'],
					'.php'
	    		)
	    	)
	    );
	    $contents = ob_get_contents();
	    ob_end_clean();
        
        return $contents;
	}
	
}
?>
